package c.j.a.d.b.m;

import android.annotation.SuppressLint;
import android.os.Process;
import c.j.a.d.b.e.f;
import c.j.a.d.b.e.n;
import c.j.a.d.b.i.h;
import com.ss.android.socialbase.downloader.g.c;

/* compiled from: DownloadChunkRunnable */
public class b implements Runnable {
    public com.ss.android.socialbase.downloader.g.b a;
    public com.ss.android.socialbase.downloader.g.b b;
    public f c;
    public c d;
    public final e e;
    public h f;
    public n g;
    public volatile boolean h;
    public volatile boolean i;
    public boolean j = false;

    static {
        Class cls = b.class;
    }

    public b(com.ss.android.socialbase.downloader.g.b bVar, c.j.a.d.b.h.c cVar, e eVar) {
        this.b = bVar;
        if (cVar != null) {
            this.d = cVar.a;
        }
        this.e = eVar;
        this.g = c.j.a.d.b.e.b.x();
        bVar = this.b;
        bVar.m = this;
        bVar.h = bVar.q();
    }

    public void a() {
        this.h = true;
        f fVar = this.c;
        if (fVar != null) {
            fVar.e();
        }
    }

    public final void b(com.ss.android.socialbase.downloader.g.b bVar, long j) {
        com.ss.android.socialbase.downloader.g.b i = bVar.h() ? bVar.i() : bVar;
        if (i != null) {
            if (i.l()) {
                this.g.k(i.a, i.e(), j);
            }
            i.f(j);
            this.g.m(i.a, i.f, i.e(), j);
        } else if (bVar.h()) {
            this.g.k(bVar.a, bVar.f, j);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:278:0x0117 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:99:0x0116 A:{Catch:{ a -> 0x0134, all -> 0x012d, all -> 0x00cc, a -> 0x00f0, all -> 0x0196 }} */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x0036  */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x0051 A:{SYNTHETIC, Splitter:B:25:0x0051} */
    /* JADX WARNING: Removed duplicated region for block: B:280:0x004d A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:211:0x0245 A:{Catch:{ a -> 0x01a8, all -> 0x01b4 }} */
    /* JADX WARNING: Removed duplicated region for block: B:207:0x023c A:{Catch:{ a -> 0x01a8, all -> 0x01b4 }} */
    /* JADX WARNING: Removed duplicated region for block: B:219:0x0255 A:{SYNTHETIC, Splitter:B:219:0x0255} */
    /* JADX WARNING: Removed duplicated region for block: B:281:0x0251 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:260:0x02af A:{Catch:{ a -> 0x01a8, all -> 0x01b4 }} */
    /* JADX WARNING: Removed duplicated region for block: B:139:0x01a2 A:{SYNTHETIC, Splitter:B:139:0x01a2} */
    /* JADX WARNING: Removed duplicated region for block: B:291:0x019e A:{SYNTHETIC, IGNORE_EDGES: B:273:0x02cb} */
    /* JADX WARNING: Removed duplicated region for block: B:158:0x01c6 A:{SYNTHETIC, Splitter:B:158:0x01c6} */
    /* JADX WARNING: Removed duplicated region for block: B:284:0x01c2 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:133:0x0196 A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:63:0x00d1} */
    /* JADX WARNING: Removed duplicated region for block: B:131:0x0192 A:{ExcHandler: all (th java.lang.Throwable), PHI: r14 , Splitter:B:112:0x014b} */
    /* JADX WARNING: Removed duplicated region for block: B:133:0x0196 A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:63:0x00d1} */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:131:0x0192, code skipped:
            r0 = th;
     */
    /* JADX WARNING: Missing block: B:132:0x0194, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:133:0x0196, code skipped:
            r0 = th;
     */
    /* JADX WARNING: Missing block: B:134:0x0197, code skipped:
            r14 = false;
     */
    /* JADX WARNING: Missing block: B:137:0x019c, code skipped:
            if (f() == false) goto L_0x01a2;
     */
    /* JADX WARNING: Missing block: B:140:?, code skipped:
            c.j.a.d.b.n.a.o(r0, "downloadChunkInner");
     */
    /* JADX WARNING: Missing block: B:141:0x01a7, code skipped:
            throw null;
     */
    /* JADX WARNING: Missing block: B:156:0x01c2, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:157:0x01c5, code skipped:
            return true;
     */
    /* JADX WARNING: Missing block: B:160:0x01ca, code skipped:
            if (c.j.a.d.b.n.a.H(r0) != false) goto L_0x01cc;
     */
    /* JADX WARNING: Missing block: B:164:?, code skipped:
            ((c.j.a.d.b.m.c) r1.e).p(r0, r14);
     */
    /* JADX WARNING: Missing block: B:165:0x01d3, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:166:0x01d6, code skipped:
            return r14;
     */
    /* JADX WARNING: Missing block: B:172:0x01df, code skipped:
            if (((c.j.a.d.b.m.c) r1.e).A(r0) != false) goto L_0x01e1;
     */
    /* JADX WARNING: Missing block: B:174:0x01e5, code skipped:
            if (r0.a == 1051) goto L_0x01e7;
     */
    /* JADX WARNING: Missing block: B:175:0x01e7, code skipped:
            r2 = 1;
     */
    /* JADX WARNING: Missing block: B:176:0x01e9, code skipped:
            r2 = null;
     */
    /* JADX WARNING: Missing block: B:177:0x01ea, code skipped:
            if (r2 != null) goto L_0x01ec;
     */
    /* JADX WARNING: Missing block: B:181:?, code skipped:
            ((c.j.a.d.b.m.c) r1.e).p(r0, true);
     */
    /* JADX WARNING: Missing block: B:182:0x01f3, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:183:0x01f6, code skipped:
            return r14;
     */
    /* JADX WARNING: Missing block: B:184:0x01f7, code skipped:
            if (r5 != false) goto L_0x01f9;
     */
    /* JADX WARNING: Missing block: B:187:0x01fb, code skipped:
            if (r1.c != null) goto L_0x01fd;
     */
    /* JADX WARNING: Missing block: B:189:0x0203, code skipped:
            if (c.j.a.c.y.a.i.s(32) != false) goto L_0x0205;
     */
    /* JADX WARNING: Missing block: B:190:0x0205, code skipped:
            r2 = r1.c;
            r3 = r2.m - r2.C;
            r2 = (r3 > 0 ? 1 : (r3 == 0 ? 0 : -1));
     */
    /* JADX WARNING: Missing block: B:191:0x020e, code skipped:
            if (r2 > 0) goto L_0x0210;
     */
    /* JADX WARNING: Missing block: B:192:0x0210, code skipped:
            b(r8, r1.c.C);
     */
    /* JADX WARNING: Missing block: B:193:0x0218, code skipped:
            if (r2 < 0) goto L_0x021a;
     */
    /* JADX WARNING: Missing block: B:195:0x021b, code skipped:
            r6 = r31;
            r22 = r1.c.m - r6;
            b(r8, r6);
     */
    /* JADX WARNING: Missing block: B:199:?, code skipped:
            ((c.j.a.d.b.m.c) r1.e).B(r0);
     */
    /* JADX WARNING: Missing block: B:200:0x022e, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:201:0x0231, code skipped:
            return r14;
     */
    /* JADX WARNING: Missing block: B:202:0x0232, code skipped:
            r3 = r22;
     */
    /* JADX WARNING: Missing block: B:206:0x023a, code skipped:
            if (c.j.a.c.y.a.i.s(16) == false) goto L_0x0245;
     */
    /* JADX WARNING: Missing block: B:210:?, code skipped:
            r0 = ((c.j.a.d.b.m.c) r1.e).h(r8, r0, r3);
     */
    /* JADX WARNING: Missing block: B:214:?, code skipped:
            r0 = ((c.j.a.d.b.m.c) r1.e).g(r0, r3);
     */
    /* JADX WARNING: Missing block: B:216:0x024f, code skipped:
            if (r0 != c.j.a.d.b.f.a.RETURN) goto L_0x0255;
     */
    /* JADX WARNING: Missing block: B:217:0x0251, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:218:0x0254, code skipped:
            return r14;
     */
    /* JADX WARNING: Missing block: B:220:?, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:223:?, code skipped:
            r2 = r1.d;
     */
    /* JADX WARNING: Missing block: B:229:0x026b, code skipped:
            r3 = r0.a;
     */
    /* JADX WARNING: Missing block: B:246:0x028f, code skipped:
            if (r3 == 1020) goto L_0x0291;
     */
    /* JADX WARNING: Missing block: B:249:0x0294, code skipped:
            if (r3 == 1049) goto L_0x02aa;
     */
    /* JADX WARNING: Missing block: B:257:0x02aa, code skipped:
            r5 = null;
     */
    /* JADX WARNING: Missing block: B:258:0x02ac, code skipped:
            r5 = 1;
     */
    /* JADX WARNING: Missing block: B:259:0x02ad, code skipped:
            if (r5 != null) goto L_0x02af;
     */
    /* JADX WARNING: Missing block: B:260:0x02af, code skipped:
            r2 = (c.j.a.d.b.m.c) r1.e;
            r3 = r2.o;
     */
    /* JADX WARNING: Missing block: B:261:0x02b5, code skipped:
            if (r3 != null) goto L_0x02b7;
     */
    /* JADX WARNING: Missing block: B:262:0x02b7, code skipped:
            r3.y0 = true;
     */
    /* JADX WARNING: Missing block: B:263:0x02b9, code skipped:
            r2.p(r0, r14);
     */
    /* JADX WARNING: Missing block: B:264:0x02bc, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:265:0x02bf, code skipped:
            return r14;
     */
    /* JADX WARNING: Missing block: B:270:?, code skipped:
            ((c.j.a.d.b.m.c) r1.e).B(r0);
     */
    /* JADX WARNING: Missing block: B:271:0x02c7, code skipped:
            e();
     */
    /* JADX WARNING: Missing block: B:272:0x02ca, code skipped:
            return r14;
     */
    public final boolean c(com.ss.android.socialbase.downloader.g.b r34) {
        /*
        r33 = this;
        r1 = r33;
        r8 = r34;
    L_0x0004:
        r0 = r34.h();
        r9 = 0;
        if (r0 == 0) goto L_0x001f;
    L_0x000b:
        r0 = r34.j();
        if (r0 == 0) goto L_0x001f;
    L_0x0011:
        r0 = r34.i();
        if (r0 == 0) goto L_0x001f;
    L_0x0017:
        r2 = r0.f;
        r3 = r8.f;
        if (r2 != r3) goto L_0x001f;
    L_0x001d:
        r10 = r0;
        goto L_0x0020;
    L_0x001f:
        r10 = r9;
    L_0x0020:
        r11 = 1;
        if (r10 == 0) goto L_0x002a;
    L_0x0023:
        r0 = r10.m();
        if (r0 == 0) goto L_0x002a;
    L_0x0029:
        return r11;
    L_0x002a:
        r2 = r34.q();
        r4 = r8.d;
        r6 = r34.q();
        if (r10 == 0) goto L_0x0040;
    L_0x0036:
        r6 = r10.q();
        r2 = r10.q();
        r4 = r10.d;
    L_0x0040:
        r18 = r2;
        r20 = r4;
        r22 = 0;
        r5 = 0;
        r0 = r33.f();	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        if (r0 == 0) goto L_0x0051;
    L_0x004d:
        r33.e();
        return r5;
    L_0x0051:
        r0 = r1.d;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        r4 = r0.f();	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        r0 = r1.f;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        if (r0 == 0) goto L_0x005d;
    L_0x005b:
        r0 = 1;
        goto L_0x005e;
    L_0x005d:
        r0 = 0;
    L_0x005e:
        r1.j = r0;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        r2 = 300; // 0x12c float:4.2E-43 double:1.48E-321;
        r3 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        if (r0 != 0) goto L_0x00d1;
    L_0x0066:
        r0 = r1.d;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r12 = r0.i;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r13 = r0.E;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r14 = r18;
        r16 = r20;
        r0 = c.j.a.d.b.n.a.j(r12, r13, r14, r16);	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r12 = new com.ss.android.socialbase.downloader.g.e;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r13 = "Chunk-Index";
        r14 = r8.f;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r14 = java.lang.String.valueOf(r14);	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r12.m4697init(r13, r14);	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r13 = r0;
        r13 = (java.util.ArrayList) r13;
        r13.add(r12);	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r12 = r1.d;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        c.j.a.d.b.n.a.p(r0, r12);	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r12 = r1.d;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r13 = r12.C;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r12 = r12.j;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r28 = 0;
        r29 = 0;
        r30 = 0;
        r24 = r13;
        r25 = r12;
        r26 = r4;
        r27 = r0;
        r0 = c.j.a.d.b.e.b.f(r24, r25, r26, r27, r28, r29, r30);	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        r1.f = r0;	 Catch:{ a -> 0x00ae, all -> 0x00a7 }
        goto L_0x00d1;
    L_0x00a7:
        r0 = move-exception;
        r4 = "ChunkRunnableConnection";
        c.j.a.d.b.n.a.o(r0, r4);	 Catch:{ all -> 0x00b0 }
        throw r9;
    L_0x00ae:
        r0 = move-exception;
        throw r0;	 Catch:{ all -> 0x00b0 }
    L_0x00b0:
        r0 = move-exception;
        r4 = r0;
        r0 = r1.f;	 Catch:{ a -> 0x00f0, all -> 0x0196 }
        if (r0 == 0) goto L_0x00d0;
    L_0x00b6:
        r10 = r1.e;	 Catch:{ a -> 0x00f0, all -> 0x0196 }
        if (r10 == 0) goto L_0x00d0;
    L_0x00ba:
        r0 = r0.b();	 Catch:{ all -> 0x00cc }
        if (r0 < r3) goto L_0x00c2;
    L_0x00c0:
        if (r0 < r2) goto L_0x00d0;
    L_0x00c2:
        r0 = r1.e;	 Catch:{ all -> 0x00cc }
        r2 = r1.f;	 Catch:{ all -> 0x00cc }
        r0 = (c.j.a.d.b.m.c) r0;
        r0.r(r2);	 Catch:{ all -> 0x00cc }
        goto L_0x00d0;
    L_0x00cc:
        r0 = move-exception;
        r0.printStackTrace();	 Catch:{ a -> 0x00f0, all -> 0x0196 }
    L_0x00d0:
        throw r4;	 Catch:{ a -> 0x00f0, all -> 0x0196 }
    L_0x00d1:
        r0 = r1.f;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        if (r0 == 0) goto L_0x00f2;
    L_0x00d5:
        r12 = r1.e;	 Catch:{ a -> 0x00f0, all -> 0x0196 }
        if (r12 == 0) goto L_0x00f2;
    L_0x00d9:
        r0 = r0.b();	 Catch:{ all -> 0x00eb }
        if (r0 < r3) goto L_0x00e1;
    L_0x00df:
        if (r0 < r2) goto L_0x00f2;
    L_0x00e1:
        r0 = r1.e;	 Catch:{ all -> 0x00eb }
        r2 = r1.f;	 Catch:{ all -> 0x00eb }
        r0 = (c.j.a.d.b.m.c) r0;
        r0.r(r2);	 Catch:{ all -> 0x00eb }
        goto L_0x00f2;
    L_0x00eb:
        r0 = move-exception;
        r0.printStackTrace();	 Catch:{ a -> 0x00f0, all -> 0x0196 }
        goto L_0x00f2;
    L_0x00f0:
        r0 = move-exception;
        goto L_0x0136;
    L_0x00f2:
        r0 = r33.f();	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        if (r0 == 0) goto L_0x00fc;
    L_0x00f8:
        r33.e();
        return r5;
    L_0x00fc:
        r0 = r1.f;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        if (r0 == 0) goto L_0x0180;
    L_0x0100:
        r2 = r1.j;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        if (r2 != 0) goto L_0x013b;
    L_0x0104:
        r0 = r0.b();	 Catch:{ a -> 0x0134, all -> 0x012d }
        r2 = c.j.a.d.b.n.a.a;	 Catch:{ a -> 0x0134, all -> 0x012d }
        r2 = 206; // 0xce float:2.89E-43 double:1.02E-321;
        if (r0 == r2) goto L_0x0113;
    L_0x010e:
        if (r0 != r3) goto L_0x0111;
    L_0x0110:
        goto L_0x0113;
    L_0x0111:
        r2 = 0;
        goto L_0x0114;
    L_0x0113:
        r2 = 1;
    L_0x0114:
        if (r2 == 0) goto L_0x0117;
    L_0x0116:
        goto L_0x013b;
    L_0x0117:
        r2 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x0134, all -> 0x012d }
        r3 = 1002; // 0x3ea float:1.404E-42 double:4.95E-321;
        r4 = "Http response error , code is : %s ";
        r10 = new java.lang.Object[r11];	 Catch:{ a -> 0x0134, all -> 0x012d }
        r0 = java.lang.String.valueOf(r0);	 Catch:{ a -> 0x0134, all -> 0x012d }
        r10[r5] = r0;	 Catch:{ a -> 0x0134, all -> 0x012d }
        r0 = java.lang.String.format(r4, r10);	 Catch:{ a -> 0x0134, all -> 0x012d }
        r2.m4677init(r3, r0);	 Catch:{ a -> 0x0134, all -> 0x012d }
        throw r2;	 Catch:{ a -> 0x0134, all -> 0x012d }
    L_0x012d:
        r0 = move-exception;
        r2 = "ChunkRunnableGetResponseCode";
        c.j.a.d.b.n.a.o(r0, r2);	 Catch:{ a -> 0x00f0, all -> 0x0196 }
        throw r9;
    L_0x0134:
        r0 = move-exception;
        throw r0;	 Catch:{ a -> 0x00f0, all -> 0x0196 }
    L_0x0136:
        r31 = r6;
        r14 = 0;
        goto L_0x01bc;
    L_0x013b:
        r0 = new c.j.a.d.b.e.f;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        r3 = r1.d;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        r12 = r1.f;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        r13 = r1.e;	 Catch:{ a -> 0x01b7, all -> 0x0196 }
        r2 = r0;
        r14 = 0;
        r5 = r12;
        r31 = r6;
        r6 = r34;
        r7 = r13;
        r2.m2407init(r3, r4, r5, r6, r7);	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r1.c = r0;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        if (r10 == 0) goto L_0x0174;
    L_0x0152:
        r2 = r10.g(r14);	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r0 = (r20 > r22 ? 1 : (r20 == r22 ? 0 : -1));
        if (r0 == 0) goto L_0x0164;
    L_0x015a:
        r0 = (r20 > r18 ? 1 : (r20 == r18 ? 0 : -1));
        if (r0 < 0) goto L_0x0164;
    L_0x015e:
        r20 = r20 - r18;
        r2 = 1;
        r2 = r20 + r2;
    L_0x0164:
        r0 = r1.c;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r4 = r10.q();	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r6 = r10.d;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r0.m = r4;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r0.n = r4;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r0.o = r6;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r0.p = r2;	 Catch:{ a -> 0x0194, all -> 0x0192 }
    L_0x0174:
        r0 = r1.c;	 Catch:{ a -> 0x017d, all -> 0x0192 }
        r0.g();	 Catch:{ a -> 0x017d, all -> 0x0192 }
        r33.e();
        return r11;
    L_0x017d:
        r0 = move-exception;
        r5 = 1;
        goto L_0x01bc;
    L_0x0180:
        r31 = r6;
        r14 = 0;
        r0 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r2 = 1022; // 0x3fe float:1.432E-42 double:5.05E-321;
        r3 = new java.io.IOException;	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r4 = "download can't continue, chunk connection is null";
        r3.<init>(r4);	 Catch:{ a -> 0x0194, all -> 0x0192 }
        r0.m4678init(r2, r3);	 Catch:{ a -> 0x0194, all -> 0x0192 }
        throw r0;	 Catch:{ a -> 0x0194, all -> 0x0192 }
    L_0x0192:
        r0 = move-exception;
        goto L_0x0198;
    L_0x0194:
        r0 = move-exception;
        goto L_0x01bb;
    L_0x0196:
        r0 = move-exception;
        r14 = 0;
    L_0x0198:
        r2 = r33.f();	 Catch:{ all -> 0x01b4 }
        if (r2 == 0) goto L_0x01a2;
    L_0x019e:
        r33.e();
        return r11;
    L_0x01a2:
        r2 = "downloadChunkInner";
        c.j.a.d.b.n.a.o(r0, r2);	 Catch:{ a -> 0x01a8 }
        throw r9;
    L_0x01a8:
        r0 = move-exception;
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r2.B(r0);	 Catch:{ all -> 0x01b4 }
        r33.e();
        return r14;
    L_0x01b4:
        r0 = move-exception;
        goto L_0x02cb;
    L_0x01b7:
        r0 = move-exception;
        r31 = r6;
        r14 = 0;
    L_0x01bb:
        r5 = 0;
    L_0x01bc:
        r2 = r33.f();	 Catch:{ all -> 0x01b4 }
        if (r2 == 0) goto L_0x01c6;
    L_0x01c2:
        r33.e();
        return r11;
    L_0x01c6:
        r2 = c.j.a.d.b.n.a.H(r0);	 Catch:{ all -> 0x01b4 }
        if (r2 == 0) goto L_0x01d7;
    L_0x01cc:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r2.p(r0, r14);	 Catch:{ all -> 0x01b4 }
        r33.e();
        return r14;
    L_0x01d7:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r2 = r2.A(r0);	 Catch:{ all -> 0x01b4 }
        if (r2 == 0) goto L_0x025d;
    L_0x01e1:
        r2 = r0.a;	 Catch:{ all -> 0x01b4 }
        r3 = 1051; // 0x41b float:1.473E-42 double:5.193E-321;
        if (r2 != r3) goto L_0x01e9;
    L_0x01e7:
        r2 = 1;
        goto L_0x01ea;
    L_0x01e9:
        r2 = 0;
    L_0x01ea:
        if (r2 == 0) goto L_0x01f7;
    L_0x01ec:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r2.p(r0, r11);	 Catch:{ all -> 0x01b4 }
        r33.e();
        return r14;
    L_0x01f7:
        if (r5 == 0) goto L_0x0232;
    L_0x01f9:
        r2 = r1.c;	 Catch:{ all -> 0x01b4 }
        if (r2 == 0) goto L_0x0227;
    L_0x01fd:
        r2 = 32;
        r2 = c.j.a.c.y.a.i.s(r2);	 Catch:{ all -> 0x01b4 }
        if (r2 == 0) goto L_0x021b;
    L_0x0205:
        r2 = r1.c;	 Catch:{ all -> 0x01b4 }
        r3 = r2.m;	 Catch:{ all -> 0x01b4 }
        r5 = r2.C;	 Catch:{ all -> 0x01b4 }
        r3 = r3 - r5;
        r2 = (r3 > r22 ? 1 : (r3 == r22 ? 0 : -1));
        if (r2 <= 0) goto L_0x0218;
    L_0x0210:
        r2 = r1.c;	 Catch:{ all -> 0x01b4 }
        r5 = r2.C;	 Catch:{ all -> 0x01b4 }
        r1.b(r8, r5);	 Catch:{ all -> 0x01b4 }
        goto L_0x0234;
    L_0x0218:
        if (r2 >= 0) goto L_0x0234;
    L_0x021a:
        goto L_0x0232;
    L_0x021b:
        r2 = r1.c;	 Catch:{ all -> 0x01b4 }
        r2 = r2.m;	 Catch:{ all -> 0x01b4 }
        r6 = r31;
        r22 = r2 - r6;
        r1.b(r8, r6);	 Catch:{ all -> 0x01b4 }
        goto L_0x0232;
    L_0x0227:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r2.B(r0);	 Catch:{ all -> 0x01b4 }
        r33.e();
        return r14;
    L_0x0232:
        r3 = r22;
    L_0x0234:
        r2 = 16;
        r2 = c.j.a.c.y.a.i.s(r2);	 Catch:{ all -> 0x01b4 }
        if (r2 == 0) goto L_0x0245;
    L_0x023c:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r0 = r2.h(r8, r0, r3);	 Catch:{ all -> 0x01b4 }
        goto L_0x024d;
    L_0x0245:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r0 = r2.g(r0, r3);	 Catch:{ all -> 0x01b4 }
    L_0x024d:
        r2 = c.j.a.d.b.f.a.RETURN;	 Catch:{ all -> 0x01b4 }
        if (r0 != r2) goto L_0x0255;
    L_0x0251:
        r33.e();
        return r14;
    L_0x0255:
        r33.e();	 Catch:{ all -> 0x01b4 }
        r33.e();
        goto L_0x0004;
    L_0x025d:
        r2 = r1.d;	 Catch:{ all -> 0x01b4 }
        r3 = r2.x0;	 Catch:{ all -> 0x01b4 }
        if (r3 == 0) goto L_0x02c0;
    L_0x0263:
        r3 = r2.y0;	 Catch:{ all -> 0x01b4 }
        if (r3 != 0) goto L_0x02c0;
    L_0x0267:
        r3 = r2.R;	 Catch:{ all -> 0x01b4 }
        if (r3 <= r11) goto L_0x02c0;
    L_0x026b:
        r3 = r0.a;	 Catch:{ all -> 0x01b4 }
        r4 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x0271:
        r4 = 1032; // 0x408 float:1.446E-42 double:5.1E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x0275:
        r4 = 1033; // 0x409 float:1.448E-42 double:5.104E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x0279:
        r4 = 1034; // 0x40a float:1.449E-42 double:5.11E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x027d:
        r4 = 1008; // 0x3f0 float:1.413E-42 double:4.98E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x0281:
        r4 = 1026; // 0x402 float:1.438E-42 double:5.07E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x0285:
        r4 = 1027; // 0x403 float:1.439E-42 double:5.074E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x0289:
        r4 = 1044; // 0x414 float:1.463E-42 double:5.16E-321;
        if (r3 == r4) goto L_0x02ac;
    L_0x028d:
        r4 = 1020; // 0x3fc float:1.43E-42 double:5.04E-321;
        if (r3 != r4) goto L_0x0292;
    L_0x0291:
        goto L_0x02ac;
    L_0x0292:
        r4 = 1049; // 0x419 float:1.47E-42 double:5.183E-321;
        if (r3 == r4) goto L_0x02aa;
    L_0x0296:
        r4 = 1055; // 0x41f float:1.478E-42 double:5.21E-321;
        if (r3 == r4) goto L_0x02aa;
    L_0x029a:
        r4 = 1006; // 0x3ee float:1.41E-42 double:4.97E-321;
        if (r3 == r4) goto L_0x02aa;
    L_0x029e:
        r2 = r2.I();	 Catch:{ all -> 0x01b4 }
        r4 = 8388608; // 0x800000 float:1.17549435E-38 double:4.144523E-317;
        r6 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r6 >= 0) goto L_0x02aa;
    L_0x02a9:
        goto L_0x02ac;
    L_0x02aa:
        r5 = 0;
        goto L_0x02ad;
    L_0x02ac:
        r5 = 1;
    L_0x02ad:
        if (r5 == 0) goto L_0x02c0;
    L_0x02af:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;	 Catch:{ all -> 0x01b4 }
        r3 = r2.o;	 Catch:{ all -> 0x01b4 }
        if (r3 == 0) goto L_0x02b9;
    L_0x02b7:
        r3.y0 = r11;	 Catch:{ all -> 0x01b4 }
    L_0x02b9:
        r2.p(r0, r14);	 Catch:{ all -> 0x01b4 }
        r33.e();
        return r14;
    L_0x02c0:
        r2 = r1.e;	 Catch:{ all -> 0x01b4 }
        r2 = (c.j.a.d.b.m.c) r2;
        r2.B(r0);	 Catch:{ all -> 0x01b4 }
        r33.e();
        return r14;
    L_0x02cb:
        r33.e();
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.b.c(com.ss.android.socialbase.downloader.g.b):boolean");
    }

    public void d() {
        this.i = true;
        f fVar = this.c;
        if (fVar != null) {
            fVar.f();
        }
    }

    public final void e() {
        h hVar = this.f;
        if (hVar != null) {
            hVar.d();
            this.f = null;
        }
    }

    public final boolean f() {
        return this.h || this.i;
    }

    @SuppressLint({"DefaultLocale"})
    public void run() {
        com.ss.android.socialbase.downloader.g.b bVar;
        Process.setThreadPriority(10);
        this.a = this.b;
        while (true) {
            try {
                bVar = this.a;
                bVar.m = this;
                bVar.h = bVar.q();
                if (!c(this.a)) {
                    this.a.d(false);
                    break;
                }
                this.a.d(false);
                if (!f()) {
                    this.a = ((c) this.e).i(this.a.f);
                    if (f() || this.a == null) {
                        break;
                    }
                    Thread.sleep(50);
                } else {
                    break;
                }
            } catch (Throwable th) {
                com.ss.android.socialbase.downloader.g.b bVar2 = this.a;
                if (bVar2 != null) {
                    bVar2.d(false);
                }
                e();
                ((c) this.e).t(this);
            }
        }
        bVar = this.a;
        if (bVar != null) {
            bVar.d(false);
        }
        e();
        ((c) this.e).t(this);
    }
}
